package com.bicon.im.service.common.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * 类功能描述
 * @author SYG
 * @date 2017/7/5
 */
@Configuration
@EnableAsync
public class ThreadPoolTaskExecutorConfig {

    private int corePoolSize = 10;

    private int maxPoolSize = 200;

    private int queueCapacity = 10;

    @Bean
    public Executor analyzeHealthLevelsAsync() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        executor.setThreadNamePrefix("analyzeHealthLevelsExecutor-");
        executor.initialize();
        return executor;
    }

    @Bean
    public Executor analyzeHealthDietAsync() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        executor.setThreadNamePrefix("analyzeHealthDietExecutor-");
        executor.initialize();
        return executor;
    }

}
